package projecteuler;

import java.util.ArrayList;

public class Problem20
{
 /*
  * 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
  *
  * What is the sum of the digits of the number 2^1000?
  */
    
    public static void main(String[] args)
    {
        long now = System.currentTimeMillis();
        ArrayList<String> digits = new ArrayList<String>();
        digits.add("1");
        int limit = 1000;
        for (int i = 2; i <= limit; i++)
        {
            Utils.multiplyNumberBy(digits, i);
        }
        int sum = 0;
        for (String s : digits)
        {
            //System.out.print(s);
            sum += Integer.parseInt(s);
        }
        System.out.println(sum);
        System.out.println("Took: " + (System.currentTimeMillis() - now) + "ms");
    }

    
}
